<h2>Query</h2>

<script type="text/javascript">
$(function() {
    var $tabs = $("#tabs").tabs();
    <?php if (!empty($this->query) && !empty($this->data)) { ?>
        $tabs.tabs('select', 1);
    <?php } ?>
});
</script>

<div id="tabs">
    <ul>
        <li><a href="#tabs-1">Query</a></li>
        <li><a href="#tabs-2">Results</a></li>
        <li><a href="#tabs-3">Recent Queries</a></li>
    </ul>

    <div id="tabs-1">
        <div class="halfWidth">
            <h3>Enter your query:</h3>
            <form method="post" action="/store/query">
                <label for="query" class="invisible">Query</label>
                <textarea id="query" name="query" cols="120" rows="10"><?php if (isset($this->query)) { echo $this->query; } ?></textarea>
                <input type="submit" value="Query"/>
            </form>
        </div>
        <div class="halfWidth">
            <div style="padding-left: 1em;">
                <h3>Prefixes</h3>
                <p>TODO Have these clickable and insert into the top of query...</p>
                <ul id="prefixes">
                    <li>http://www.w3.org/1999/02/22-rdf-syntax-ns#</li>
                    <li>http://purl.org/dc/elements/1.1/</li>
                    <li>http://purl.org/dc/terms/</li>
                    <li>http://xmlns.com/foaf/0.1/</li>
                    <li>http://rdfs.org/sioc/ns#</li>
                    <li>http://purl.org/ontology/bibo/</li>
                    <li>http://purl.org/vocab/resourcelist/schema#</li>
                    <li>http://purl.org/vocab/aiiso/schema#</li>
                </ul>
            </div>
        </div>
        <div class="clear"></div>
    </div>

    <div id="tabs-2">
        <?php if (!empty($this->data)) { ?>
            <?php $this->dataRenderer->render($this->data); ?>
        <?php } ?>
    </div>

    <div id="tabs-3">
        <?php if (isset($this->recentQueries)) { ?>
            <?php krsort($this->recentQueries); ?>
            <ol>
                <?php foreach ($this->recentQueries as $recentQuery) { ?>
                    <li><a href="/store/query?query=<?php echo urlencode($recentQuery); ?>"><?php echo htmlspecialchars($recentQuery); ?></a></li>
                <?php } ?>
            </ol>
        <?php } ?>
    </div>

</div>

<script type="text/javascript" src="/js/query.js"></script>
